<?php
/**
* エラーチェッククラス
**/
require_once( '../system/Class_M_DAO.php' );
class Class_M_PATTERN_BLOCK extends Class_M_DAO {
	//protected properties begin
	/**
	 *
	 * テーブル名
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	protected $_table = "M_PATTERN_BLOCK";
	
	/**
	 *
	 * 主キー名
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	protected $_pkey = "id";
	
	/**
	 *
	 * ソート順
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	 protected $_order = "id";
	 

	 
	 protected $_cols  = array(
		"pattern_cd"    => array(AOKI_VARTYPE_INT),
		"block_cd"      => array(AOKI_VARTYPE_STR)
	 );
	
	 protected $_checks  = array(
		"pattern_cd"     => array( "EXIST" ),
		"media_flg"       => array( "EXIST" )
	 );
	 
	 //maxlength 
	 protected $_maxlens  = array(

	 );
	 
	public function getFormBlock($value ) {
		if (empty($value)) {
			$sql = "SELECT a.block_cd,a.block_name,'' as pblock_cd  FROM M_BLOCK  a ";
		}else {
			$sql = "SELECT a.block_cd,a.block_name,b.block_cd as pblock_cd  FROM M_BLOCK  a left join M_PATTERN_BLOCK b on b.block_cd = a.block_cd and b.pattern_cd = {$value}";
		}
		
		try {
			$this->_db->query( $sql );
			$data = array();
			while( $row = $this->_db->fetch() ){
				$data[] = $row;
			}
			return $data;
		} catch (Exception $e) {
			echo "例外キャッチ：", $e->getMessage(), "\n";
			return NULL;
		}
	}
}

?>